—

Title: Information Visualization Project 1

Name: Kavleen Kaur

Output: html_notebook and R notebook


The project focuses on mapping the whiskey distillery dataset to our best of abilities. This project helps us to find few answers based on visualization. Visualization of any dataset helps us understand the dataset better and also help us answer some of he questions better. Thus, this dataset is also visualized in order to fully understand the dataset.

But due to many reasons, this visualizatin is limited. We will also discuss the limitation of this visualization and also critique the visualization to best of our capabilities and thus this project will involve all the aspects of visualization.


Loading the required libraries.

library(sp)
library(sf)
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1
library(rgdal)
## Please note that rgdal will be retired by the end of 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
## 
## rgdal: version: 1.5-27, (SVN revision 1148)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29
## Path to GDAL shared files: C:/Users/prabhdeep/Documents/R/win-library/4.1/rgdal/gdal
## GDAL binary built with GEOS: TRUE 
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Users/prabhdeep/Documents/R/win-library/4.1/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.4-5
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
## Overwritten PROJ_LIB was C:/Users/prabhdeep/Documents/R/win-library/4.1/rgdal/proj
library(classInt) 
library(RColorBrewer) # not a strictly a spatial ligrary
library(viridis) #my current "go to" color scales
## Loading required package: viridisLite
library(ggmap)
## Loading required package: ggplot2
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(leaflet)
library(tmap)
## Registered S3 methods overwritten by 'stars':
##   method             from
##   st_bbox.SpatRaster sf  
##   st_crs.SpatRaster  sf
library(GISTools)
## Loading required package: maptools
## Checking rgeos availability: TRUE
## Please note that 'maptools' will be retired by the end of 2023,
## plan transition at your earliest convenience;
## some functionality will be moved to 'sp'.
## Loading required package: MASS
## Loading required package: rgeos
## rgeos version: 0.5-8, (SVN revision 679)
##  GEOS runtime version: 3.9.1-CAPI-1.14.2 
##  Please note that rgeos will be retired by the end of 2023,
## plan transition to sf functions using GEOS at your earliest convenience.
##  GEOS using OverlayNG
##  Linking to sp version: 1.4-5 
##  Polygon checking: TRUE
library(knitr) # to create nice documents in R
library(tidyverse) # loads ggplot2, dplyr,tidyr,readr,purr,tibble
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble  3.1.5     v dplyr   1.0.7
## v tidyr   1.1.4     v stringr 1.4.0
## v readr   2.0.2     v forcats 0.5.1
## v purrr   0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## x dplyr::select() masks MASS::select()
library(broom)  # because I find it useful
library(forcats) # working with categorical variables

Loading the dataset and forming the dataframes.

whiskey <- read_csv("Real whiskey dataset.csv")
## Rows: 86 Columns: 17
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr  (2): Distillery, Postcode
## dbl (15): RowID, Body, Sweetness, Smoky, Medicinal, Tobacco, Honey, Spicy, W...
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
whiskey$Longitude <- as.numeric(whiskey$Longitude)
whiskey$Latitude <- as.numeric(whiskey$Latitude)
str(whiskey)
## spec_tbl_df [86 x 17] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ RowID     : num [1:86] 1 2 3 4 5 6 7 8 9 10 ...
##  $ Distillery: chr [1:86] "Aberfeldy" "Aberlour" "AnCnoc" "Ardbeg" ...
##  $ Body      : num [1:86] 2 3 1 4 2 2 0 2 2 2 ...
##  $ Sweetness : num [1:86] 2 3 3 1 2 3 2 3 2 3 ...
##  $ Smoky     : num [1:86] 2 1 2 4 2 1 0 1 1 2 ...
##  $ Medicinal : num [1:86] 0 0 0 4 0 1 0 0 0 1 ...
##  $ Tobacco   : num [1:86] 0 0 0 0 0 0 0 0 0 0 ...
##  $ Honey     : num [1:86] 2 4 2 0 1 1 1 2 1 0 ...
##  $ Spicy     : num [1:86] 1 3 0 2 1 1 1 1 0 2 ...
##  $ Winey     : num [1:86] 2 2 0 0 1 1 0 2 0 0 ...
##  $ Nutty     : num [1:86] 2 2 2 1 2 0 2 2 2 2 ...
##  $ Malty     : num [1:86] 2 3 2 2 3 1 2 2 2 1 ...
##  $ Fruity    : num [1:86] 2 3 3 1 1 1 3 2 2 2 ...
##  $ Floral    : num [1:86] 2 2 2 0 1 2 3 1 2 1 ...
##  $ Postcode  : chr [1:86] "PH15 2EB" "AB38 9PJ" "AB5 5LI" "PA42 7EB" ...
##  $ Latitude  : num [1:86] 286580 326340 352960 141560 355350 ...
##  $ Longitude : num [1:86] 749680 842570 839320 646220 829140 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   RowID = col_double(),
##   ..   Distillery = col_character(),
##   ..   Body = col_double(),
##   ..   Sweetness = col_double(),
##   ..   Smoky = col_double(),
##   ..   Medicinal = col_double(),
##   ..   Tobacco = col_double(),
##   ..   Honey = col_double(),
##   ..   Spicy = col_double(),
##   ..   Winey = col_double(),
##   ..   Nutty = col_double(),
##   ..   Malty = col_double(),
##   ..   Fruity = col_double(),
##   ..   Floral = col_double(),
##   ..   Postcode = col_character(),
##   ..   Latitude = col_double(),
##   ..   Longitude = col_double()
##   .. )
##  - attr(*, "problems")=<externalptr>

Data needed for the visualization.

library(maps)
## 
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
## 
##     map
## The following object is masked from 'package:GISTools':
## 
##     map.scale
## The following object is masked from 'package:viridis':
## 
##     unemp
world.map <- map_data ("world")
glimpse(world.map)
## Rows: 99,338
## Columns: 6
## $ long      <dbl> -69.89912, -69.89571, -69.94219, -70.00415, -70.06612, -70.0~
## $ lat       <dbl> 12.45200, 12.42300, 12.43853, 12.50049, 12.54697, 12.59707, ~
## $ group     <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ~
## $ order     <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 1~
## $ region    <chr> "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba~
## $ subregion <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ~

Map Vizualization.

This is the initial visualization that does not include any interaction.

UK.map <- world.map %>% filter(region == "UK")
whiskies.coord <- data.frame(whiskey$Latitude, whiskey$Longitude)
coordinates(whiskies.coord) <- ~whiskey.Latitude + whiskey.Longitude
proj4string(whiskies.coord) <- CRS("+init=epsg:27700")
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum OSGB_1936 in Proj4 definition
whiskies.coord <- spTransform(whiskies.coord, CRS("+init=epsg:4326"))
whisky.map <- data.frame(Distillery = whiskey$Distillery,
lat = whiskies.coord$whiskey.Latitude,
long = whiskies.coord$whiskey.Longitude)
UK.map %>%
  filter(subregion == "Scotland") %>% ggplot() + 
  geom_map(map = UK.map,aes(x = long, y = lat, map_id = region),fill="White", colour = "Black")+ coord_map() + geom_point(data = whisky.map,aes(x=lat, y = long, colour = "red", alpha = 0.9))
## Warning: Ignoring unknown aesthetics: x, y

Visualization 2

Using leaflet, to produce a basic map with very less interaction. Here in this map, we can zoom in order to see any distillery’s location clearly with the help of markers.

whiskey_db<-cbind(whisky.map,whiskey$Body,whiskey$Sweetness,whiskey$Smoky,whiskey$Medicinal,whiskey$Tobacco,whiskey$Honey,whiskey$Spicy,whiskey$Winey,whiskey$Nutty,whiskey$Malty,whiskey$Fruity,whiskey$Floral,whiskey$Postcode)
library(leaflet)
library(dplyr)
map<-leaflet()%>%
  addTiles()%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat)
map

Visualization 3

Here in this map, we can zoom in order to see any distillery’s location clearly through the marker but also know the distilleries information by clicking on the specific marker of any distillery. Thus, the map’s effectiveness is increased by increasing the interaction of the map with its audience. The image below show the interaction level of the map under visualization 3

library(leaflet)
library(dplyr)
map<-leaflet()%>%
  addTiles()%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))
map

#Here is the interaction

Visualization 4

Here in this map, we can zoom in order to see any distillery’s location clearly through the marker but also know the distilleries information by clicking on the specific marker of any distillery. Here, the map’s effectiveness is increased by adding customized markers that connects the map with audience with its presentation as to showcasing exactly what the map represents ( Location of distilleries). The image below show the interaction level of the map under visualization 4

library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://th.bing.com/th/id/R.ea3d8777c865475529457f6bdae5cdad?rik=Gdii5m0%2b54%2fUpw&riu=http%3a%2f%2fpngimg.com%2fuploads%2fwhisky%2fwhisky_PNG62.png&ehk=fO165RiE%2f61zY9bzAjVu1nQ1t%2b18iLob4YToocqd2LQ%3d&risl=&pid=ImgRaw&r=0",iconWidth=35,iconHeight=75)
map<-leaflet()%>%
  addTiles()%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))
map

#Here is the interaction with customized marker

Visualization 5

Here in this map, we can zoom in order to see any distillery’s location clearly through the marker but also know the distilleries information by clicking on the specific marker of any distillery. Here, the map’s effectiveness is increased by adding customized markers that connects the map with audience with its presentation as to showcasing exactly what the map represents ( Location of distilleries) but also the marker has been changed in this one because of the mess that marker was making. Also, this visualization has been made better by adding setView so that the view should look not messier and also pleasing to the eyes. The image below show the interaction level of the map under visualization 5

library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
  addTiles()%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))
setView(map,lng=-2.4333,lat=53.5500,zoom=9)

#Here is the interaction with customized marker

Visualization 6

Here in this map, we can zoom in order to see any distillery’s location clearly through the marker but also know the distilleries information by clicking on the specific marker of any distillery. Here, the map’s effectiveness is increased by adding by adding setView and also a MINI MAP which hepls us to easily find where are we currently, at what location of the country are we at. It increases the interaction of the map and makes the interaction for the audience easier.Thus, the view should look not messier and also can be interacted effectively through the Mini map.

library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
  addTiles()%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))%>%addMiniMap()
setView(map,lng=-2.4333,lat=53.5500,zoom=9)

Visualization 7

Here in this map, in order to avoid the mess in the graph, we have added clusters of distilleries using the cluster option which are near to each other.The clusters are interctive and when are pressed, the show indivisual distillery which carries their indivisual information. Here, the map’s effectiveness is increased by adding by interactive clusters makes the map less messier and as they are interactive too, the audience can easily open them up for more information. It aslo helps us to understand which distilleries are in the vicinity of each other. THE CLUSTERS CAN BE EXPANDED BY CLICKING ON THEM.

library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
  addTiles()%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,clusterOptions = markerClusterOptions(),popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))%>%addMiniMap()
setView(map,lng=-2.4333,lat=53.5500,zoom=9)

Visualization 8

Here in this map, apart from everything, the information of the indivisual distillery is shown in an effective way. The image below show the interaction level of the map under visualization 8

library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
  addTiles()%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()
setView(map,lng=-2.4333,lat=53.5500,zoom=9)

#Here is the better looking information table

Visualization 9

Here in this map, we have added the title to the graph and also added a control layer to the graph. The image below shows the real output of the code though the html avoids showcasing the title of the map.

library(leaflet)
library(dplyr)
library(htmlwidgets)
 library(htmltools)
tag.map.title <- tags$style(HTML("
  .leaflet-control.map-title {
    transform: translate(-50%,5%);
    position: fixed !important;
    left: 50%;
    text-align: center;
    color: black;
    background:white;
    font-weight: bold;
    font-size: 15px;
  }
"))
title <- tags$div(
  tag.map.title, HTML("Whiskey Distillery Mapping:Based On Location")
)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
  addTiles(group = "Based on Location")%>%
  addControl(title, position = "topleft", className="map-title")%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%
  addLayersControl(baseGroups = c("Based on Location"))
setView(map,lng=-2.4333,lat=53.5500,zoom=9)

#Here is the real output with title and the control layer

Visualization 10

Here in this map, we have markers factored on the bases of body and also the icons for the markers are customized. After clustering, the markers carry indisual colours evident through the legend added in the map and these markers are factored on the basis of body of the distillery. The image below shows the real output of the code though the html avoids showcasing the title of the map.

library(leaflet)
library(dplyr)
library(htmlwidgets)
 library(htmltools)
library(raster)
## 
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
## 
##     select
## The following object is masked from 'package:MASS':
## 
##     select
tag.map.title <- tags$style(HTML("
  .leaflet-control.map-title {
    transform: translate(-50%,5%);
    position: fixed !important;
    left: 50%;
    text-align: center;
    color: black;
    background:white;
    font-weight: bold;
    font-size: 15px;
  }
"))
title <- tags$div(
  tag.map.title, HTML("Whiskey Distillery Mapping:Based On Body")
)
whiskey_db$`whiskey$Body` <- factor(whiskey_db$`whiskey$Body`)
new <- c("red", "green","blue","orange","yellow")[whiskey_db$`whiskey$Body`]

icons <- awesomeIcons(
  icon = 'ios-close',
  iconColor = 'black',
  library = 'ion',
  markerColor = new
)
unique_markers_map <- leaflet(whiskey_db$`whiskey$Body`)%>%
  addTiles(group = "Based on Body")%>%
  addControl(title, position = "topleft", className="map-title")%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addAwesomeMarkers(lng=UK.map$long,lat=UK.map$lat,icon=icons,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%addLegend(color="yellow",labels="Body 1")%>%addLegend(color="green",labels="Body 1")%>%addLegend(color="blue",labels="Body 2")%>%addLegend(color="orange",labels="Body 3")%>%addLegend(color="red",labels="Body 4")%>%
  addLayersControl(baseGroups = c("Based on Body"))
setView(unique_markers_map,lng=-2.4333,lat=53.5500,zoom=9)

#Here is the visualization of the markers factored on the basis of body

Visualization 11

Here in this map, we have markers factored on the bases of spicy feature and also the icons for the markers are customized. After clustering, the markers carry indisual colours evident through the legend added in the map and these markers are factored on the basis of spicy feature of the distillery.

library(leaflet)
library(dplyr)
library(htmlwidgets)
 library(htmltools)
library(raster)
tag.map.title <- tags$style(HTML("
  .leaflet-control.map-title {
    transform: translate(-50%,5%);
    position: fixed !important;
    left: 50%;
    text-align: center;
    color: black;
    background:white;
    font-weight: bold;
    font-size: 15px;
  }
"))
title <- tags$div(
  tag.map.title, HTML("Whiskey Distillery Mapping:Based On Spicy")
)
whiskey_db$`whiskey$Spicy` <- factor(whiskey_db$`whiskey$Spicy`)
new <- c("red", "green","blue","orange","yellow")[whiskey_db$`whiskey$Spicy`]

icons <- awesomeIcons(
  icon = 'ios-close',
  iconColor = 'black',
  library = 'ion',
  markerColor = new
)
unique_markers_map <- leaflet(whiskey_db$`whiskey$Spicy`)%>%
  addTiles(group = "Based on Spicy")%>%
  addControl(title, position = "topleft", className="map-title")%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addAwesomeMarkers(lng=UK.map$long,lat=UK.map$lat,icon=icons,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%addLegend(color="yellow",labels="Spicy 1")%>%addLegend(color="green",labels="Spicy 1")%>%addLegend(color="blue",labels="Spicy 2")%>%addLegend(color="orange",labels="Spicy 3")%>%addLegend(color="#ff0000",labels="Spicy 4")%>%
  addLayersControl(baseGroups = c("Based on Spicy"))
setView(unique_markers_map,lng=-2.4333,lat=53.5500,zoom=9)

Visualization 12

Here in this map, we have markers factored on the bases of sweetness feature and also the icons for the markers are customized. After clustering, the markers carry indisual colours evident through the legend added in the map and these markers are factored on the basis of sweetness feature of the distillery.

library(leaflet)
library(dplyr)
library(htmlwidgets)
 library(htmltools)
library(raster)
tag.map.title <- tags$style(HTML("
  .leaflet-control.map-title {
    transform: translate(-50%,5%);
    position: fixed !important;
    left: 50%;
    text-align: center;
    color: black;
    background:white;
    font-weight: bold;
    font-size: 15px;
  }
"))
title <- tags$div(
  tag.map.title, HTML("Whiskey Distillery Mapping:Based On Sweetness")
)
whiskey_db$`whiskey$Sweetness` <- factor(whiskey_db$`whiskey$Sweetness`)
new <- c("red", "green","blue","orange","yellow")[whiskey_db$`whiskey$Sweetness`]

icons <- awesomeIcons(
  icon = 'ios-close',
  iconColor = 'black',
  library = 'ion',
  markerColor = new
)
unique_markers_map <- leaflet(whiskey_db$`whiskey$Sweetness`)%>%
  addTiles(group = "Based on Sweetness")%>%
  addControl(title, position = "topleft", className="map-title")%>%
  addProviderTiles(providers$OpenStreetMap)%>%
  addAwesomeMarkers(lng=UK.map$long,lat=UK.map$lat,icon=icons,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%addLegend(color="yellow",labels="Sweetness 1")%>%addLegend(color="green",labels="Sweetness 1")%>%addLegend(color="blue",labels="Sweetness 2")%>%addLegend(color="orange",labels="Sweetness 3")%>%addLegend(color="red",labels="Sweetness 4")%>%
  addLayersControl(baseGroups = c("Based on Sweetness"))
setView(unique_markers_map,lng=-2.4333,lat=53.5500,zoom=9)

Rest all the other features, could be produced the same way.

Analysis done:

  1. Based on location:

The intended visualization was much effective as apart from just knowing the location, we inteded to increase the interactivity of the map by adding waterfall plot that could help compare nearby distilleries by clicking on the clustered markers but it could be only achieved through shiny. For, the current visualization, from a user’s perspective, it was crucial to know where the distilleries were located and the best way that could be achieved was through a map. The map also shows the distilleries information which would be very useful when once know the location of the distillery.

  1. Based on all features.

Features of the distilleries could be compared with shiny by creating an onclick event thrugh shiny and producing a bubble chart or radar plot but here, in this visualization, we have focused on based on features, if a user wants to know the place of the distillery, could know it through a map. The coloured markers are associated with the fetaure type and offcouse the markers contain other information as well.

Limitation:

  1. The analysis could have more grapghs like radar plot, waterfall plot and bubble graph to draw comparisons between the distilleries in the vicinity but it could require to use shiny along with leaflet as alone leaflet does not have on click feature. Thus, restricted us to the work produced.

Scope:

  1. Use shiny to add onclick graphs and then this visualization could be a lot better.
  2. Shiny could also be used for making better looking dashboards.

Critiquing the map produced.

The map contains a proper view set through SetView that produces the desired zoomed view, the provider is selected keeping in mind proper display of the map. To avoid clustering clusterOption is used. LayerControl and Mini Maps also added for the right reason. Interactivity through a map is produced to the maximum limit but the map does not have the desired legend table. The legends produced are not at all effective.